﻿using Application.AppSrevices;
using Application.Dto;
using Application.IAppSrevices;
using AutoMapper;
using Domain.Entitys;
using Microsoft.AspNetCore.Mvc;

namespace UI.Controllers
{
    public class SSDController : Controller
    {
        private readonly IMapper mapper;
        private readonly ISSDService sSDService;

        public SSDController(ISSDService sSDService, IMapper mapper)
        {
            this.mapper = mapper;
            this.sSDService = sSDService;
        }

        //public IActionResult Index()
        //{
        //    return View();
        //}
        public IActionResult Index()
        {
            Console.WriteLine(22);
            return View();
        }
        public IActionResult SSDAdd()
        {
            Console.WriteLine(22);
            return View();
        }
        /// <summary>
        /// 薪酬标准单详细信息分页查询
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        /// 
        public async Task< IActionResult> SSDSelect(int pageIndex, int pageSize)
        { 
            IEnumerable <SSD>sSDs=await sSDService.SSDselectAsync(pageIndex, pageSize);
            return Json(sSDs);
        }
        /// <summary>
        /// 薪酬标准单详细信息总页数
        /// </summary>
        /// <returns></returns>
        /// 
        public IActionResult SelectCount()
        {
            int count = sSDService.SSDSelectCount();
            return Json(count);
        }
        /// <summary>
        /// 薪酬标注单详细信息页数
        /// </summary>
        /// <param name="sSDDeleteDto"></param>
        /// <returns></returns>
        public async Task<IActionResult> SSDDelete(SSDDeleteDto sSDDeleteDto) { 
             int zhi= await   sSDService.SSDdelectAsync(sSDDeleteDto);
            return Json(zhi);
        }
        /// <summary>
        /// 薪酬标注单详细信息添加
        /// </summary>
        /// <returns></returns>
        /// 
        //[HttpPost]
        //public async Task< IActionResult> SSDAdd(SSDAddDto sSDAddDto) {
        //    //if (ModelState.IsValid) {
        //        int ren =   await sSDService.SSDAddAsync(sSDAddDto);
        //        if (ren > 0)
        //        {
        //            TempData["SSDadd"] = "添加成功";
        //            return  RedirectToAction("Index");
        //        }
        //        else {
        //            TempData["SSDadd"] = "添加失败";
        //            return RedirectToAction("SSDAdd");
        //        }
        //    //}
        //    //TempData["SSDadd"] = "没有提交";
        //    //return View();
        //}
    }
}
